Skip to content

Add support for declarative ESD configuration#7

Merged
nex3 merged 2 commits intoarchipelago-nextfrom
ezstate-config
Mar 3, 2026
Merged

Add support for declarative ESD configuration#7
nex3 merged 2 commits intoarchipelago-nextfrom
ezstate-config

Conversation

@nex3
Copy link
Collaborator

@nex3 nex3 commented Feb 9, 2026

Based on APIs added in fswap/SoulsIds#1

@nex3 nex3 requested a review from nhyldmar February 9, 2026 00:11
@nex3 nex3 requested review from a team and removed request for nhyldmar February 20, 2026 00:41
@zer0x64
Copy link

zer0x64 commented Feb 20, 2026

I can take this review! Will need to learn a bit about ESD before I can approve, but that doesn't seem like wasted time since it's used in all fromsoft games apparently

@nex3 nex3 requested review from zer0x64 and removed request for a team February 20, 2026 04:01
@nex3
Copy link
Collaborator Author

nex3 commented Feb 28, 2026

@zer0x64 Are you still planning to review this? It's blocking all the other PRs for 4.1.0, so at some point I'll just need to land it.

@zer0x64
Copy link

zer0x64 commented Feb 28, 2026

@zer0x64 Are you still planning to review this? It's blocking all the other PRs for 4.1.0, so at some point I'll just need to land it.

Sorry for lack of updates. I'll sit on this tomorrow! If I don't, don't wait on me, I'm spread thinner than I thought these days 🫠

Copy link

@zer0x64 zer0x64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing major, only a few questions and recommendations.

On another note, like I said I'm spread thinner than expected these days, so I won't self-assign an issue like this until I learn a bit more about the codebase and have a bit less projects in parallel.

events,
ESDDocumentation.DeserializeFromFile(
$@"{game.Dir}\Base\ds3.esd.json",
new ESDDocumentation.DocOptions() { Game = "ds3" }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this function, there's a lot of non-generic references to DS3. Is this because the other games uses another form, or is it because they are not implemented yet? (using this flow at least)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter—we only have Archipelago support for DS3. You can see a draft of Sekiro support in #15, but I'm waiting to put that out for review until I can verify it with an end-to-end prototype.

/// </summary>
public class ExistingState
{
// TODO: Group and state numbers are auto-assigned by the compiler and thus subject to
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't to it right now, but I could work on the research side a bit on this when I'll come back if nobody started yet. I assume this is a major blocker for version-independant mod

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be helpful. It's not clear right now how important being version-independent is in the short term—DS3 and Sekiro are unlikely to get any more patches that modify their event code, and we probably won't get to ER before Tarnished Edition lands. But if we ever expand this to new games (or use it for other types of mods) it'll matter a lot.

{
if (!esd.StateGroups.TryGetValue(0x7FFFFFFF - Group, out var group))
{
throw new Exception($"ESD {esd.Name} doesn't have a state group {Group}");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pointing out that the esd parameter here is only used for error formatting. Might or might not want to remove it altogether, depending wether you value error clarity or code bloat/readability more(since from a high level view, this argument is not used)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a weirdness in how C# kinda hides variable assignments in if statements, but it is actually used—if this if statement succeeds, esd.StateGroups is used to assign group, which is then used below to assign state, which is what we actually do the edits to.

/// </returns>
private bool MatchArguments(Command command, ESDDocumentation doc)
{
if (Arguments.Count > command.Arguments.Count) return false;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: != instead of >. Might be missing some context here, but from an isolated look, if arguments matches, they should have the same Count

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an intentional feature that listing fewer arguments matches longer calls, to avoid a bunch of , null, null, null, null]s all over.

Comment on lines +293 to +302
var editTypes = 0;
if (Replace.Count > 0) editTypes++;
if (Set != null) editTypes++;
if (Arguments.Count > 0) editTypes++;
if (AndAlso != null) editTypes++;
if (OrElse != null) editTypes++;
if (editTypes > 1)
{
throw new Exception("Each ExpressionModifier may only contain one edit");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See related comment above, an if statement seems clearer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one would be tricky to replace with a single if clause. Since we're checking if any two edits are active, it would need O(n^2) clauses to represent the full set of checks—one for each pair.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

@nex3 nex3 requested a review from zer0x64 March 1, 2026 23:14
Comment on lines +293 to +302
var editTypes = 0;
if (Replace.Count > 0) editTypes++;
if (Set != null) editTypes++;
if (Arguments.Count > 0) editTypes++;
if (AndAlso != null) editTypes++;
if (OrElse != null) editTypes++;
if (editTypes > 1)
{
throw new Exception("Each ExpressionModifier may only contain one edit");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

@nex3 nex3 merged commit 6db19b0 into archipelago-next Mar 3, 2026
@nex3 nex3 deleted the ezstate-config branch March 3, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants